package com.sqlist.shareserver.util;

import com.sqlist.shareserver.dto.LocationDTO;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class LocationMap {
    private ConcurrentHashMap<String, LocationDTO> locationMap = new ConcurrentHashMap<>();

    private LocationMap() {
        LocationDTO locationDTO = new LocationDTO(31.00, 121.0);
        locationMap.put("zhu", locationDTO);
    }

    public LocationDTO getLocaitonDTO(String username) {
        return locationMap.get(username);
    }

    public void addLocationDTO(String username, LocationDTO locationDTO) {
        locationMap.put(username, locationDTO);
    }

    public void removeLocationDTO(String username) {
        locationMap.remove(username);
    }

    public void removeLocationDTO(LocationDTO locationDTO) {
        locationMap.remove(locationDTO);
    }

    public ConcurrentHashMap<String, LocationDTO> getLocationMap() {
        return locationMap;
    }
}
